//
//  PEFeedBackCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/11/28.
//

#import "RHFeedBackTypeCell.h"
#import "RHChioceRegionTypeVC.h"
#import "RHTools.h"
@interface RHFeedBackTypeCell()
@property (nonatomic, strong) QMUILabel *contentLab;
@property (nonatomic, strong) NSArray *typeArr;
@end
@implementation RHFeedBackTypeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setupUI];
        self.typeArr = @[@"客诉".rh_localized,@"产品建议".rh_localized];
    }
    return self;
}
-(void)setupUI{
    self.contentView.backgroundColor = CFTabViewBgColor;
    //反馈类型
    UIView *containView = kView;
    containView.backgroundColor = [UIColor whiteColor];
    [containView setMiddleBorder];
    [self.contentView addSubview:containView];
    [containView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.bottom.mas_offset(0);
    }];
    
   
    
    UIView *BgView = kView;
    BgView.backgroundColor = kCOLOR_HEX(@"#F4F6F9");
    [containView addSubview:BgView];
    [BgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.mas_offset(5);
        make.height.offset(50);
        make.bottom.mas_offset(-5);
    }];
    
    QMUILabel *contentLab = [[QMUILabel alloc]init];
    contentLab.text = @"请选择反馈类型".rh_localized;
    contentLab.font = [UIFont systemFontOfSize:14];
    contentLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.8];
    [BgView addSubview:contentLab];
    self.contentLab = contentLab;
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.centerY.mas_offset(0);
    }];
    
    UIImageView *arrowImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"nav_arrow_down"]];
    arrowImg.contentMode = UIViewContentModeScaleAspectFit;
    [BgView addSubview:arrowImg];
    [arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(15);
        make.right.mas_offset(-15);
        make.centerY.mas_offset(0);
    }];
    
    QMUIButton *selectBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
    [BgView addSubview:selectBtn];
    [selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    
    kWeakSelf;
    [[selectBtn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
        RHChioceRegionTypeVC *vc = [[RHChioceRegionTypeVC alloc]initWithTitle:@"请选择反馈类型".rh_localized Data:self.typeArr];
        vc.selectBlock = ^(NSInteger index) {
            weakSelf.contentLab.text = weakSelf.typeArr[index];
            [weakSelf.para setObject:@(index+1) forKey:weakSelf.key];
            if(weakSelf.selectBlock){
                weakSelf.selectBlock();
            }
        };
        [[RHWindowTipManage shareWindowTipManage] showWithController:vc];
    }];
}

@end
